import util from "../../util";
import parentCollection from '../parent/parentCollection';

export default class biCollection extends parentCollection{
    constructor(path) {
        super(biCollection, util.api.Bi);
    }
    static create(record, path){
        let object=new biCollection(path);
        return object;
    }
    async queryInfoAll(){
        let result = await this.api.queryInfoAll().then(data=>{
            if(!!data) {
                this.info = data;
                this.recordsTree = util.getTree(data, 'type', 'className')
                this.recordsCascader = util.getCascader(data, 'type', 'className')
                return true;
            }else{
                return false;
            }
        }).catch(err=>{
            return false;
        });
        return result;
    }
    async queryInfo(filter){
        let result = await this.api.queryInfo({condition:filter}).then(data=>{
            if(!!data) {
                this.info = data;
                this.recordsTree = util.getTree(data, 'type', 'className')
                this.recordsCascader = util.getCascader(data, 'type', 'className')
                return true;
            }else{
                return false;
            }
        }).catch(err=>{
            return false;
        });
        return result;
    }
}
